/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.statementView;
/**
 * 说明：
 * 资金报表
 * @Author：
 * @Date：2012-03-21
 */
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import com.ruipengkj.component.jlist.ListButtonCellRenderer;
import com.ruipengkj.component.jlist.ListNodeButton;
import com.ruipengkj.component.jlist.StatementListPanel;
import com.ruipengkj.view.base.BasePanel;

public class StatementMoneyPanel extends BasePanel implements ListSelectionListener {
private static final long serialVersionUID = 1L;
	
	private StatementMoneyCharge statementMoneyCharge;//应收款汇总表显示按钮
	private StatementMoneyPay statementMoneyPay;//应付款汇总表
	private MarketMoneyInOntPanel marketMoneyInOntPanel;//资金出入面板
	
	private CardLayout right_layout;
	private JPanel right_panel;
	private DefaultListModel listModel;
	private JList btnList;//功能按钮列表
	public StatementMoneyPanel() {
		this.setLayout(new BorderLayout());
		this.init();
	}
	
	private void init() {
		listModel=new DefaultListModel();
		listModel.addElement(new ListNodeButton("应收款汇总表"));
		listModel.addElement(new ListNodeButton("应付款汇总表"));
		listModel.addElement(new ListNodeButton("资金出入"));
		btnList=new StatementListPanel();
		btnList.setFixedCellHeight(35);
		btnList.setModel(listModel);
		btnList.setCellRenderer(new ListButtonCellRenderer());
		btnList.addListSelectionListener(this);
		btnList.setBackground(new Color(245, 250, 255));
		JSplitPane jsp = new JSplitPane();
		jsp.add(btnList, JSplitPane.LEFT, 0);
		jsp.add(initRight(), JSplitPane.RIGHT, 0);
		jsp.setDividerLocation(180);
		this.add(jsp, BorderLayout.CENTER);
		this.add(uiFactory.createFlowJPanel(), BorderLayout.SOUTH);
		SwingUtilities.invokeLater(statementMoneyCharge);
	}
	
	
	private JPanel initRight() {
		right_layout = new CardLayout();
		right_panel = new JPanel(right_layout);
		
		statementMoneyCharge = new StatementMoneyCharge();
		right_panel.add(statementMoneyCharge, "a");
		right_layout.show(right_panel, "a");
		SwingUtilities.invokeLater(statementMoneyCharge);
		return right_panel;
	}
	
	@Override
	public void clear() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void valueChanged(ListSelectionEvent e) {
		switch (btnList.getSelectedIndex()) {
		case 0: {
			// 应收款汇总表
			statementMoneyCharge = new StatementMoneyCharge();
			right_panel.add(statementMoneyCharge, "a");
			right_layout.show(right_panel, "a");
			SwingUtilities.invokeLater(statementMoneyCharge);
			break;
		}
		case 1: {
			// 应付款汇总表
			statementMoneyPay = new StatementMoneyPay();
			right_panel.add(statementMoneyPay, "b");
			right_layout.show(right_panel, "b");
			SwingUtilities.invokeLater(statementMoneyPay);
			break;
		}
		case 2: 
			marketMoneyInOntPanel = new MarketMoneyInOntPanel();
			right_panel.add(marketMoneyInOntPanel,"c");
			right_layout.show(right_panel, "c");
			SwingUtilities.invokeLater(marketMoneyInOntPanel);
		}
	}
}
